const fs = require("fs");
const dir = require("../dir.js");
const log = require("../log.js");
const paramReplaceReg = /[\\/]{[^{}]+}/g;
const splitReg = /[\\/ _-]+[^\\/ _-]/;

function toCamel(str = ""){
  str = str.replace(/^[\\/]/, "").replace(/[\\/]+/, " ").replace(paramReplaceReg, "").replace(/{[^{}]+}/g, " ");
  while (splitReg.test(str)) {
    str = str.replace(splitReg, function () {
      return arguments[0][1].toUpperCase();
    })
  }
  return str;
}

module.exports = function (conf) {
  const list = dir.deepReadDir(conf.inputPath, conf.fileReg);
  fs.writeFileSync(conf.outputPath,JSON.stringify(list));
  log.t(`write ${conf.outputPath} success!`).end();
};
